package com.milloc.db.dto;

import lombok.Data;
import org.springframework.data.domain.Page;

import java.util.List;

/**
 * @author gongdeming
 * @create 2019-08-27
 */
@Data
public class PageOutDTO<T> {
    private int pageSize;
    private int pageNum;
    private int total;

    private List<T> list;

    public static <T> PageOutDTO<T> from(Page<T> page) {
        PageOutDTO<T> pageOutDTO = new PageOutDTO<>();
        pageOutDTO.setPageSize(page.getSize());
        pageOutDTO.setPageNum(page.getNumber());
        pageOutDTO.setTotal(page.getTotalPages());
        pageOutDTO.setList(page.getContent());
        return pageOutDTO;
    }
}
